<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

/**
 * Admin Category Model
 *
 */
class Admin_Category_Tree_Model extends CI_Model {

	function __construct() {
		parent::__construct();
		log_message('debug', 'Init Model Initialized');
		$config = array('table'=>'category_tree');
		$this->load->library('mahana_hierarchy');
		$this->mahana_hierarchy->initialize($config);
		
	}
	
	function get_cetegory($status=51){
		$sql="select * from category_tree where status=$status order by id ASC";
		$query = $this->db->query($sql);
		$result = $query->result();
		if ($result){
			return $result;
		} else {
			return false;
		}
	}
	function get_cetegory_data($cate_id=NULL){
		$sql="select * from category_tree where id=$cate_id";
		$query = $this->db->query($sql);
		$row = $query->row();
		if ($row){
			return $row;
		} else {
			return false;
		}
	}
	public function category_delete($id=NULL) {
	
		$this->db->where('id', $id);
		$this->db->delete('category_tree');
	

	}
	
	function get_parent($parent_id=0)
	{
		$sql = "Select * from category_tree where parent_id=$parent_id and status=51";
		$query = $this->db->query($sql);
		$result = $query->result();
		if ($result){
			return $result;
		} else {
			return false;
		}
	}
	function get_keyword_category($status=51)
	{
		$sql="select * from category_tree where status=$status";
		$query = $this->db->query($sql);
		$result = $query->result();
		if ($result){
			return $result;
		} else {
			return false;
		}
	
	}
}